define [
  'jquery', 'knockout', 'mapping', 'underscore', 'DataSource'
], ($, ko, mapping, _, DataSource) ->
  ko.extenders.DataSource = DataSource

  class comboModel
    constructor: (@parent, @data) ->
      mapping.fromJS @data, {}, @

  class viewModel
    constructor: ->
      @rows = ko.observableArray([]).extend {
        DataSource:
          url: 'demo/'
          versionType: 0
          pageType: 1
          setTotalPage: (target, data) ->
            target.totalPage 1
          success: (target, data) =>
            if not data.status
              return false
            target _.map data.data.combos, (combo) =>
              new comboModel @, combo
            true
      }
      @rows.fetch()

  $ ->
    ko.applyBindings new viewModel()


    var index = 1;
        function changeTab(id) {
        if (index != id) {
        document.getElementById('tab' + index).className = '';
        document.getElementById('tab' + id).className = 'selected';
        document.getElementById('list' + index).style.display = 'none';
        document.getElementById('list' + id).style.display = 'block';
        index = id;
        }
        }

        function ScrollImgLeft() {

        var speed = 20

        var scroll_begin = document.getElementById("scroll_begin");

        var scroll_end = document.getElementById("scroll_end");

        var scroll_div = document.getElementById("scroll_div");

        scroll_end.innerHTML = scroll_begin.innerHTML

        function Marquee() {

        if (scroll_end.offsetWidth - scroll_div.scrollLeft <= 0)

        scroll_div.scrollLeft -= scroll_begin.offsetWidth

        else

        scroll_div.scrollLeft++

        }

        var MyMar = setInterval(Marquee, speed)

        scroll_div.onmouseover = function () { clearInterval(MyMar) }

        scroll_div.onmouseout = function () { MyMar = setInterval(Marquee, speed) }

        }
